package com.wx.mall.sys.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.wx.mall.sys.entity.Admin;
import com.wx.mall.sys.mapper.RoleMapper;
import com.wx.mall.sys.mapper.UserMapper;
import com.wx.mall.sys.mapper.UserRoleMapper;
import com.wx.mall.sys.service.IUserService;
import com.wx.mall.sys.vo.req.UserPageReqVO;
import com.wx.mall.sys.vo.resp.PageVO;
import com.wx.mall.sys.vo.resp.UserPageRespVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户表 服务实现类
 * </p>
 *
 * @author j
 * @since 2020-03-17
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, Admin> implements IUserService {
    @Autowired
    private UserMapper userMapper;
    @Autowired
    private RoleMapper roleMapper;
    @Autowired
    private UserRoleMapper userRoleMapper;

    @Override
    public PageVO findPage(UserPageReqVO vo) {
        Page<Object> objectPage = PageHelper.startPage(vo.getPageNum(), vo.getPageSize());
        List<UserPageRespVO> page = userMapper.findPage(vo);
        PageVO pageVO = new PageVO();
        pageVO.setList(page);
        pageVO.setTotalRows(objectPage.getTotal());
        return pageVO;
    }
}
